package com.dhecp.project.system.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dhecp.common.annotation.Log;
import com.dhecp.common.annotation.RepeatSubmit;
import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.domain.AjaxResult;
import com.dhecp.core.layui.GridColumnsPropertyModel;
import com.dhecp.core.layui.TreeDataModel;
import com.dhecp.core.layui.TreeDataUtil;
import com.dhecp.core.layui.TreeSelectDataModel;
import com.dhecp.core.layui.TreeSelectDataUtil;
import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.common.enums.BusinessType;
import com.dhecp.core.utils.ReadExcel;
import com.dhecp.core.utils.ValidationUtils;
import com.dhecp.core.constant.ModuleTable;
import com.dhecp.project.system.domain.SysOrganizationInfo;
import com.dhecp.project.system.domain.SysUserInfo;
import com.dhecp.project.system.service.SysOrganizationInfoService;
import com.dhecp.project.system.service.SysUserInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 组织机构信息
 */
@Controller
@RequestMapping("/system/organization")
public class SysOrganizationController extends BaseController {
    private String prefix = "system/organization";
    private String moduleTable = ModuleTable.ORGANIZATION_INFO;

    @Autowired
    private SysOrganizationInfoService organizationInfoService;

    @Autowired
    private GridColumnsPropertyModel gridColumnsPropertyModel;
    
    @Autowired
    private SysUserInfoService userInfoService;

    @Autowired
    private TreeDataUtil treeDataUtil;

    @Autowired
    private TreeSelectDataUtil treeSelectDataUtil;

    @RequiresPermissions("system:organization:view")
    @GetMapping()
    public String organization(@RequestParam Map<String, Object> params)
    {
    	return prefix + "/organization";
    }

//    @RequiresPermissions("system:organization:list")
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map<String, Object> params){
    	params.put("moduleTable", moduleTable);
        List<SysOrganizationInfo> list = new ArrayList<SysOrganizationInfo>();
        try {
            list = organizationInfoService.queryOrganizationInfo(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());            
        }
        return getDataTable(list);
    }

    /**
     * 打开组织机构新增
     * @param params
     * @return ModelAndView
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:add")
    @GetMapping("/add")
    public Object organizationInfoAdd(@RequestParam Map<String, Object> params){
        ModelAndView mv = this.getModelAndView();
        //必要参数orgKind（新增机构类型）：取值 company（新增公司）， dept（新增部门）
        //必要参数porgKind（上级机构类型）：取值 company（上级为公司）， dept（上级为部门），若选中的是顶级则默认（company）
        //必要参数pguid（上级机构唯一值（guid））：若新增的是顶级则默认（root）
        if (mv.isEmpty()){
            mv = this.gotoModelAndViewErrorPage(params, "orgKind","新增机构类型（company 或 dept）");
        }
        if (mv.isEmpty()){
            mv = this.gotoModelAndViewErrorPage(params, "porgKind","上级机构类型（company 或 dept），若选中的是顶级则默认（company）");
        }
        if (mv.isEmpty()){
            mv = this.gotoModelAndViewErrorPage(params, "pguid","上级机构唯一值（guid），若新增的是顶级则默认（root）");
        }
        if (mv.isEmpty()){
            String orgNameSelected;	//选中的机构节点名称
            if (params.get("orgNameSelected") != null && params.get("orgNameSelected") != ""){
                orgNameSelected = params.get("orgNameSelected").toString();
            }else{
                orgNameSelected = "未知节点";
            }
            AjaxResult ajaxResult = new AjaxResult();
            if ("company".equals(params.get("orgKind").toString().toLowerCase()) && "dept".equals(params.get("porgKind").toString().toLowerCase())){
                ajaxResult = AjaxResult.error("不能在部门中添加公司。");
            }else{
                ajaxResult = AjaxResult.success("参数合理。");
            }
            mv.addObject("ajaxResult", ajaxResult);
            mv.addObject("orgNameSelected", orgNameSelected);
            mv.addObject("orgKind", params.get("orgKind").toString());
            mv.addObject("pguid", params.get("pguid").toString());
            mv.setViewName(prefix + "/organization_add");
        }
        return mv;
    }

    /**
     * 打开组织机构修改
     * @param params
     * @return ModelAndView
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:edit")
    @GetMapping("/edit")
    public ModelAndView organizationInfoEdit(@RequestParam Map<String, Object> params){
        ModelAndView mv = this.getModelAndView();
        if (mv.isEmpty()){
            mv = this.gotoModelAndViewErrorPage(params, "guid","机构唯一值");
        }
        if (mv.isEmpty()){
            AjaxResult ajaxResult = new AjaxResult();
            try{
                SysOrganizationInfo organizationInfo = organizationInfoService.queryOrganizationInfoByGuid(params.get("guid").toString());
                if (organizationInfo == null){
                    ajaxResult = AjaxResult.error("没有符合条件的数据。");
                }else{
                    ajaxResult = AjaxResult.success("查询成功。");
                }
                mv.addObject("organizationInfo", organizationInfo);
                mv.addObject("pguid", organizationInfo.getPguid());
            }catch(Exception e){
                ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
            }
            mv.addObject("ajaxResult", ajaxResult);
            mv.setViewName(prefix + "/organization_add");
        }
        return mv;
    }

    /**
     * 1、打开组织机构管理者分配页面(pagetype=managers)
     * 2、打开部门分配用户页面(pagetype=users)
     * @param params
     * @return ModelAndView
     * @author DH-Xxj
     */
    @GetMapping("/orgusersadd")
    public ModelAndView organizationInfoUsersAdd(@RequestParam Map<String, Object> params){
        ModelAndView mv = this.getModelAndView();
        if (mv.isEmpty()){
            mv = this.gotoModelAndViewErrorPage(params, "pagetype","页面类型：managers（分配管理者），users（分配用户）");
        }
        if (mv.isEmpty()){
            mv = this.gotoModelAndViewErrorPage(params, "guid","机构唯一值");
        }
        if (mv.isEmpty()){
            mv = this.gotoModelAndViewErrorPage(params, "orgKind","机构类型");
        }
        if (mv.isEmpty()){
            String pagetype = params.get("pagetype").toString();
            String pagetitle = "managers".equals(pagetype)?"分配管理者":"分配用户";
            mv.addObject("pagetype", pagetype);
            mv.addObject("pagetitle", pagetitle);
            mv.setViewName(prefix + "/orgusers_add");
        }
        return mv;
    }
    /**
     * 打开部门选择页面
     * @param params
     * @return ModelAndView
     * @author kimiloo
     */
    @GetMapping("/select")
    public ModelAndView selectModule(@RequestParam Map<String, Object> params){
        ModelAndView mv = this.getModelAndView();
        mv.setViewName(prefix + "/dept_select");
        return mv;
    }
    
    /**
     * 打开公司、部门选择页面
     * @param params
     * @return ModelAndView
     */
    @GetMapping("/selectB")
    public ModelAndView selectDept(@RequestParam Map<String, Object> params){
    	params.put("moduleTable", moduleTable);
    	params.put("entity", new SysOrganizationInfo()); //生成表格gridColumns对应的实体，用于获取实体属性生成表格字段
    	params.put("toolBarWidth", 0);
    	if(params.get("pagetype") !=null && params.get("pagetype").toString().equalsIgnoreCase("checkbox"))params.put("checkBox", "yes");
        else params.put("radio", "yes");
        ModelAndView mv = this.getModelAndView();
        AjaxResult ajaxResult = new AjaxResult();
        mv.addObject("ajaxResult", ajaxResult);
        mv.addObject("gridColumns", gridColumnsPropertyModel.queryGridColumnsPropertyModel(params));
        mv.addObject("prefix", prefix);
        mv.addObject("moduleTable", moduleTable);
        mv.setViewName("common/select");
        return mv;
    }

    /**
     * 打开组织机构对象
     * @param pagetype ：必要参数【页面类型：radio（单选），checkbox（多选）】
     * @param selectedObject ：已选中的织机构对象字符串，示例：(user)1001;(user)1002;(user)1003;(dept)D103;(company)C101
     * @return ModelAndView
     * @author DH-Xxj
     */
    @RequiresPermissions("system:user:view")
    @GetMapping("/orgObjectSelect")
    public ModelAndView orgInfoSelectList(@RequestParam Map<String, Object> params){
        ModelAndView mv = this.getModelAndView();
        params.put("moduleTable", moduleTable);
        mv = this.gotoModelAndViewErrorPage(params, "pagetype","页面类型：radio（单选），checkbox（多选）");
        if (mv.isEmpty()){
            String pagetype = "checkbox".equals(params.get("pagetype").toString())?"checkbox":"radio";
            if (params.get("selectedObject") != null && params.get("selectedObject") != ""){
                String selectedObject = params.get("selectedObject").toString();
                mv.addObject("selectedObject", selectedObject);
            }
            mv.addObject("pagetype", pagetype);
            if("direct".equals(params.get("by").toString())){
                mv.setViewName(prefix + "/orgobject_direct_select");
            }else{
                mv.setViewName(prefix + "/orgobject_select");
            }
        }
        return mv;
    }
    
    /**
     * 通过guid查询单条记录
     * @param guid
     * @return MessageModel
     * @throws Exception
     * @author DH-Xxj
     */
    @RequestMapping("/lineguid")
    @ResponseBody
    public AjaxResult organizationInfolineJsonByGuid(@RequestParam(required = false, defaultValue = "no", value = "guid") String guid)
    {
        AjaxResult ajaxResult = new AjaxResult();
        try{
            SysOrganizationInfo organizationInfo = organizationInfoService.queryOrganizationInfoByGuid(guid);
            if (organizationInfo == null){
                ajaxResult =  AjaxResult.error("没有符合条件的数据。");
            }else{
                ajaxResult = AjaxResult.success("查询成功。", organizationInfo);
            }
        }catch(Exception e){
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 通过orgid查询单条记录
     * @param orgid
     * @return MessageModel
     * @throws Exception
     * @author DH-Xxj
     */
    @RequestMapping("/lineorgid")
    @ResponseBody
    public AjaxResult organizationInfolineJsonByOrgid(@RequestParam(required = false, defaultValue = "no", value = "orgid") String orgid){
        AjaxResult ajaxResult = new AjaxResult();
        try{
            SysOrganizationInfo organizationInfo = organizationInfoService.queryOrganizationInfoByOrgid(orgid);
            if (organizationInfo == null){
                ajaxResult =  AjaxResult.error("没有符合条件的数据。");
            }else{
                ajaxResult = AjaxResult.success("查询成功。", organizationInfo);
            }
        }catch(Exception e){
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 获取组织机构树
     * @param params
     * @return List
     * @throws Exception
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:list")
    @RequestMapping("/listtreejson")
    @ResponseBody
    public Object organizationInfoTreeJson(@RequestParam Map<String, Object> params) {
        List<TreeDataModel> treeDataModelList = new ArrayList<TreeDataModel>();
        try{
            treeDataModelList = organizationInfoService.queryOrganizationInfoTree(params);
            treeDataModelList = treeDataUtil.dealTreeDataModel(treeDataModelList,treeDataModelList.get(0).getMaxlevels());
        }catch(Exception e){
            return treeDataModelList;
        }
        return treeDataModelList;
    }

    /**
     * 获取组织机构树（含复选框）
     * @param vOrgs 原本已指定的机构（格式为：C101.D101,C101.D103），若不为空，则在机构选择树中默认为选中状态。 
     * @return List
     * @throws Exception
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:list")
    @RequestMapping("/listtreeselectjson")
    @ResponseBody
    public Object organizationInfoTreeSelectJson(@RequestParam Map<String, Object> params) {
        List<TreeSelectDataModel> treeSelectDataModelList = new ArrayList<TreeSelectDataModel>();
        String[] vOrgsList = null;
//        params.put("vOrgs", "C101.D101,C101.D103");
        if (params.get("vOrgs") != null){
        	String vOrgs = params.get("vOrgs").toString();
    		try{
	    		vOrgs = params.get("vOrgs").toString();
	    		vOrgsList = vOrgs.split(",");
			}catch(Exception e){
				e.printStackTrace();
			}
        }
        
        try{
            treeSelectDataModelList = organizationInfoService.queryOrganizationInfoTreeSelectNoUser(params);
            for(TreeSelectDataModel treeSelectDataModel : treeSelectDataModelList){
            	if (vOrgsList != null && ValidationUtils.ifStringStartsWithList(treeSelectDataModel.getOrgPathAll(), vOrgsList)){
                    Map<String,String> checkArr = new LinkedHashMap<String,String>();
                    checkArr.put("type", "0");
                    checkArr.put("checked", "1");
                	treeSelectDataModel.setCheckArr(checkArr);
            	}else{
                    Map<String,String> checkArr = new LinkedHashMap<String,String>();
                    checkArr.put("type", "0");
            		checkArr.put("checked", "0");
                	treeSelectDataModel.setCheckArr(checkArr);
            	}
            }
            treeSelectDataModelList = treeSelectDataUtil.dealTreeSelectDataModel(treeSelectDataModelList,treeSelectDataModelList.get(0).getMaxlevels());
        }catch(Exception e){
            return treeSelectDataModelList;
        }
        return treeSelectDataModelList;
    }

    /**
     * 通过用户编号或用户名称查询用户信息
     * @param params
     * @param userIdOrUserName 必要参数：用户编号 或 用户名称
     * @return GridDataModel
     * @throws Exception
     * @author DH-Xxj
     */
    @RequestMapping("/userlistbyidornamejson")
    @ResponseBody
    public TableDataInfo organizationInfoUserListByUserIdOrUserNameJson(@RequestParam Map<String, Object> params) throws Exception{
        List<SysUserInfo> list = new ArrayList<SysUserInfo>();
        try {
            if (params.get("userIdOrUserName") != null){
                list = userInfoService.queryUserListByUserIdOrUserName(params);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString()); 
        }
        return getDataTable(list);
    }

    /**
     * 查询选中机构节点下的所有用户
     * @param params
     * @return GridDataModel
     * @throws Exception
     * @author DH-Xxj
     */
    @RequestMapping("/userlistjson")
    @ResponseBody
    public TableDataInfo organizationInfoUserListJson(@RequestParam Map<String, Object> params) throws Exception{
        List<SysUserInfo> list = new ArrayList<SysUserInfo>();
        try {
                list = userInfoService.queryUserListByOrgPathAll(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString()); 
        }
        return getDataTable(list);
    }

    /**
     * 查询选中机构节点的管理者列表
     * @param params
     * @return GridDataModel
     * @throws Exception
     * @author DH-Xxj
     */
    @RequestMapping("/managersAlllistjson")
    @ResponseBody
    public TableDataInfo organizationInfoManagersAllListJson(@RequestParam Map<String, Object> params){
        List<SysUserInfo> list = new ArrayList<SysUserInfo>();
        try {
            list = userInfoService.queryManagersAllListByOrgPathAll(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString()); 
        }
        return getDataTable(list);
    }
    
    /**
     * 查询调入组织机构对象
     * @param params
     * @return TableDataInfo
     * @author DH-Xxj
     */
    @RequestMapping("/orgObject")
    @ResponseBody
    public TableDataInfo organizationInfoObject(@RequestParam Map<String, Object> params){
    	if (params.get("moduleTable") == null || params.get("moduleTable") == ""){
        	params.put("moduleTable", moduleTable);
    	}
        List<SysOrganizationInfo> list = new ArrayList<SysOrganizationInfo>();
        try {
            list = organizationInfoService.queryOrganizationInfoObject(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString()); 
        }
        return getDataTable(list);
    }
    
    /**
     * 查询已选中的组织机构对象
     * @param selectedObject ：已选中的组织机构对象字符串，示例：(user)1001;(user)1002;(user)1003;(dept)D103;(company)C101
     * @return TableDataInfo
     * @author DH-Xxj
     */
    @RequestMapping("/orgObjected")
    @ResponseBody
    public TableDataInfo organizationInfoObjectSelect(@RequestParam Map<String, Object> params){
    	if (params.get("moduleTable") == null || params.get("moduleTable") == ""){
        	params.put("moduleTable", moduleTable);
    	}
        List<SysOrganizationInfo> list = new ArrayList<SysOrganizationInfo>();
        if (params.get("selectedObject") != null && params.get("selectedObject") != ""){
        	String selectedObject = params.get("selectedObject").toString().replace(";", "','");
    		String wherestrhand = "'(' + t1.OrgKind + ')' + t1.Orgid in ('" + selectedObject + "')";
    		params.put("wherestrhand", wherestrhand);
            try {
                list = organizationInfoService.queryOrganizationInfoObject(params);
            } catch (Exception e) {
                return getDataTable(this.getExceptionMessage(e).toString()); 
            }
        }else{
    		return getDataTable("请传入已选中的组织机构对象字符串（selectedObject），取值示例：(user)1001;(user)1002;(user)1003;(dept)D103;(company)C101");
    	}
        
        return getDataTable(list);
    }

    /**
     * 在组织机构下新增员工（本地）
     */
    @GetMapping("/adduserpostLocal")
    @ResponseBody
    public AjaxResult adduserpostLocal() {
        AjaxResult ajaxResult = new AjaxResult();
        
        try {
            List<List<String>> rows = ReadExcel.getRowsByFile("d:\\Users\\Administrator\\Desktop\\导入ERP\\用户信息.xlsx", 1);
            for (int i = 1; i < rows.size(); i++) {
            	List<String> row = rows.get(i);
            	
            	String nameOrg = row.get(2);
            	SysOrganizationInfo sysOrganizationInfo = organizationInfoService.queryOrganizationInfoByOrgName(nameOrg);
            	if (sysOrganizationInfo == null) {
            		System.out.println("此条数据查询不到机构信息---" + JSON.toJSONString(row));
					continue;
				}
                Map<String, Object> params = new HashMap<String, Object>();
                params.put("pguid", sysOrganizationInfo.getGuid());
                
                JSONArray JA = new JSONArray();
                JSONObject JO = new JSONObject();
                JO.put("orgId", row.get(0));
                JO.put("orgName", row.get(1));
                JA.add(JO);
                params.put("userList", JA.toJSONString());
                ajaxResult= organizationInfoService.insertOrganizationInfoUser(params);
            }
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 分配用户——数据提交
     * @param pguid 必要参数： 上级机构唯一值
     * @param userList 必要参数：对应实体类的json格式字符串(orgid:用户编号,orgName:用户名称)
     * @return MessageModel
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:add")
    @Log(title = "组织机构新增用户", businessType = BusinessType.INSERT)
    @PostMapping("/adduserpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult organizationInfoAddUserPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= organizationInfoService.insertOrganizationInfoUser(params);
        }catch(Exception e){
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 分配管理者——数据提交
     * @param guid 必要参数： 要分配管理者的机构唯一值
     * @param userList 必要参数：对应实体类的json格式字符串(orgid:用户编号)
     * @return MessageModel
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:add")
    @Log(title = "组织机构分配管理用户", businessType = BusinessType.INSERT)
    @PostMapping("/addorgmanagerspost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult organizationInfoAddOrgManagersPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= organizationInfoService.insertOrgManagersByGuid(params);
        }catch(Exception e){
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 通过orgid删除机构中指定的用户
     * @param params
     * 		必要参数：orgid（用户编号）
     * @return MessageModel
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:delete")
    @Log(title = "组织机构删除指定的用户", businessType = BusinessType.DELETE)
    @PostMapping("/deleteuserpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult organizationInfoDeleteUserPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= organizationInfoService.deleteUserByOrgid(params);
        }catch(Exception e){
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 删除指定的管理者
     * @param params
     * 		必要参数：guid（要删除管理者的机构唯一值）
     * 		必要参数：orgid（要删除的管理者用户编号）
     * @return MessageModel
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:delete")
    @Log(title = "组织机构删除指定的管理者", businessType = BusinessType.DELETE)
    @PostMapping("/deleteorgmanagerspost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult organizationInfoDeleteOrgManagersPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= organizationInfoService.deleteOrgManagersByGuid(params);
        }catch(Exception e){
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 通过guid修改机构上级（机构转移）
     * @param params
     * 		必要参数：guid（要修改的机构唯一值）
     * 		必要参数：pguid（修改后的上级机构唯一值,上级guid）
     * @return MessageModel
     * @author DH-Xxj
     */
    @RequiresPermissions("system:organization:edit")
    @Log(title = "组织机构修改机构上级", businessType = BusinessType.UPDATE)
    @PostMapping("/editpguidpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult organizationInfoEditPguidPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= organizationInfoService.updatePguidByGuid(params);
        }catch(Exception e){
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }
    /**
     * 查询所有部门
     * @param params
     * @return TableDataInfo
     * @author kimiloo
     */
//    @RequiresPermissions("system:organization:list")
    @RequestMapping("/listbydepe")
    @ResponseBody
    public TableDataInfo listbydepe(@RequestParam Map<String, Object> params){
    	params.put("moduleTable", moduleTable);
        List<SysOrganizationInfo> list = new ArrayList<SysOrganizationInfo>();
        try {
            list = organizationInfoService.queryDeptInfo(params);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());            
        }
        return getDataTable(list);
    }
}
